#include <iostream>
#include "CodeGennerate\FileGenerate.h"
#include "RpcChannel.h"
class TestRpc
{
public:
	std::map<std::string, int> GetTotalScore(std::map<std::string, std::map<std::string, int>> mapVal)
	{
		std::map<std::string, int> Score;
		for (auto item : mapVal)
		{
			int nTotal = 0;
			for (auto it : item.second)
			{
				nTotal += it.second;
			}
			Score[item.first] = nTotal;
		}
		return Score;
	}

	bool Login(std::string& strUser, std::string& strPwd)
	{
		return strUser == "admin" && strPwd == "admin123";
	}
};

int main()
{

	CFileGenerate hppFile("TestRpc_Stub");
	hppFile.AddInclude("RpcChannel.h");
	ClassDefPtr cls(new ClassDef("TestRpc_Stub"));

	CCtorFuncDefPtr ctorDef(new CCtorFuncDef("CRpcChannelPtr", "implChannel"));
	ctorDef->AddInit("m_pImplChannel", "implChannel");
	cls->AddCtorFunc(ctorDef);
	CFuncDefPtr func(new CFuncDef("GetTotalScore", &TestRpc::GetTotalScore));
	func->AddReturn(CVariableDef<CRpcChannelProxy>("", "m_pImplChannel").Call("RemoteCall<std::map<std::string, int>>", ConstString("&TestRpc::GetTotalScore"), "param0").GetCode());

	cls->AddMemFunc(func);
	cls->AddMemVariable<CRpcChannelPtr>("m_pImplChannel");
	hppFile.AddClass(cls);

	hppFile.DumpHppFile("E:\\Student\\CApplication\\zeroRpc\\");
	
	return 0;
}